home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / fractal / kaos.lha / fixptlib / usrfun2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-27  |  1.0 KB  |  43 lines

  1. /*
  2. Compute Jacobian and value of nonlinear eq (f^r(x) - x - xoffset)
  3. by finite difference method
  4. -----------------------------
  5. NOTE:    nonlinear equations are not handled in periodic coords
  6. Input:    r=period of an orbit, n=phase space dimension,
  7.     x[n],x2[n] = coords of two current guesses
  8. Output:    alpha[n][n]=DF(x) (Jacobian), beta[n]=F(x)
  9. */
  10.  
  11. void usrfun2(x,x2,alpha,beta,r,n)
  12. double *x,*x2,**alpha,*beta;
  13. int r,n;
  14. {
  15.     int i,k;
  16.     extern double *t_va,*t_vf,*xoffset;
  17.  
  18.     /* xoffset need to be installed later */
  19.     for(i=0;i<n;i++) xoffset[i] = 0;
  20.  
  21.     /* F(x) */
  22.     for(i=0;i<n;i++) t_vf[i] = x[i];
  23.     fmap_user(t_vf,r,n);
  24.     for(i=0;i<n;i++) t_va[i] = t_vf[i]-x[i] - xoffset[i];
  25.  
  26.     /* DF(x) by finite difference */
  27.     for(k=0;k<n;k++){
  28.         for(i=0;i<n;i++) t_vf[i] = x[i];
  29.         t_vf[k] = x2[k];
  30.         fmap_user(t_vf,r,n);
  31.         /* dist = f^r(x) - x - xoffset */
  32.         for(i=0;i<n;i++){
  33.             if(i==k)
  34.                 t_vf[i] -= (x2[i] + xoffset[i]);
  35.             else
  36.                 t_vf[i] -= (x[i] + xoffset[i]);
  37.         }
  38.         for(i=0;i<n;i++) alpha[i][k] = (t_vf[i]-t_va[i])/(x2[k]-x[k]);
  39.     }
  40.  
  41.     for(i=0;i<n;i++) beta[i]=t_va[i];
  42. }
  43.